package roborally.program.command;

import java.util.List;

import roborally.program.text.TextManipulation;
import be.kuleuven.cs.som.annotate.Basic;
import be.kuleuven.cs.som.annotate.Immutable;
import be.kuleuven.cs.som.annotate.Raw;

/**
 * A class representing a sequence of commands.
 * 
 * @author Molderez Tom, 2de bach Ingenieurswetenschappen Computerwetenschappen-Elektrotechniek and Reniers Jorn, 2de bach Ingenieurswetenschappen Werktuigkunde-Computerwetenschappen
 * @version 1.0
 *
 */
public class SequenceCommand extends FlowCommand {
	
	/**
	 * Creates a new SequenceCommand.
	 * 
	 * @param commands A collection containing the internal commands of this SequenceCommand.
	 * @post For every command in commands, according the order, this new will contain the specific command.
	 * @throws IllegalArgumentException
	 * 		When the commands are not valid according isValidInternalCommands.
	 * 		| !isValidInternalCommands(commands)
	 */
	public SequenceCommand(List<? extends Command> commands) throws IllegalArgumentException {
		super(commands);
	}

	/**
	 * Returns a String representation of this SequenceCommand.
	 * 
	 * @param leftSpaces The amount of left spaces this sequence command must
	 * be added to each new line.
	 * @return A String containing this sequence commant with the interal commands, each
	 * on a new line and separated by the required brackets where needed.
	 */
	@Override
	public String write(String leftSpaces) {
		String write = leftSpaces + "(" + SEQ + "\n";
		write = write + super.write(leftSpaces + TextManipulation.LEFT_SPACE) + leftSpaces + ")\n";
		return write;
	}
	
	/**
	 * Returns the textual source code of this type of command.
	 */
	@Immutable @Basic @Raw
	public static final String getWord() {
		return SEQ;
	}
	
	/**
	 * The source code word of the SequenceCommand.
	 */
	private static final String SEQ  = "seq";

}
